FROM kkarczmarczyk/node-yarn:8.0-slim AS build-env

WORKDIR /app

ADD package.json yarn.lock /tmp/
RUN cd /tmp && yarn
RUN mkdir -p /app && cd /app && ln -s /tmp/node_modules

COPY . /app

RUN npm run build:docker

FROM node:8-alpine
WORKDIR /app
COPY package.json package-lock.json server.js /app/
RUN npm install --only=prod
COPY --from=build-env /app/dist ./dist

EXPOSE 8080
CMD [ "npm", "run", "docker" ]
